<?php

class Comment_activity_model extends CI_Model{
    public function __construct() {
        parent::__construct();
        $this->load->database();
    }
    private $tbl = 'comment_activity';
    function addComment($id_ac,$id_u,$content) {
        $this->load->helper('date');
        
        $data = array(
            'id_activity' => $id_ac,
            'id_user' => $id_u,
            'content' => $content,
            'date' => now()
        );
        
        return $this->db->insert($this->tbl, $data);
    }
    function loadComment($id_ac, $limit = NULL, $offset = NULL) {
        $this->db->select();
        $this->db->from($this->tbl);
        $this->db->join('users', $this->tbl.'.id_user = users.id_user');
        $this->db->where('id_activity', $id_ac);
        $this->db->limit($limit, $offset);
        return $this->db->get();
    }
}

